<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="等级" prop="lvl">
        <el-input
          v-model="queryParams.lvl"
          placeholder="请输入等级"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产业类型" prop="lx">
        <el-input
          v-model="queryParams.lx"
          placeholder="请输入产业类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="一级分类" prop="cpcc">
        <el-input
          v-model="queryParams.cpcc"
          placeholder="请输入一级分类"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="二级分类" prop="cpmc">
        <el-input
          v-model="queryParams.cpmc"
          placeholder="请输入二级分类"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="三级分类" prop="cpxf">
        <el-input
          v-model="queryParams.cpxf"
          placeholder="请输入三级分类"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="观察日期" prop="mon">
        <el-input
          v-model="queryParams.mon"
          placeholder="请输入观察日期"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="企业总数" prop="qys">
        <el-input
          v-model="queryParams.qys"
          placeholder="请输入企业总数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="全市企业总数" prop="ctQs">
        <el-input
          v-model="queryParams.ctQs"
          placeholder="请输入全市企业总数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="纳税金额" prop="taxAmount">
        <el-input
          v-model="queryParams.taxAmount"
          placeholder="请输入纳税金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="纳税金额_全市" prop="taxAmountQs">
        <el-input
          v-model="queryParams.taxAmountQs"
          placeholder="请输入纳税金额_全市"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="社保人数" prop="sbPersonCount">
        <el-input
          v-model="queryParams.sbPersonCount"
          placeholder="请输入社保人数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="社保金额" prop="sbPayAmontSum">
        <el-input
          v-model="queryParams.sbPayAmontSum"
          placeholder="请输入社保金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="社保人数_全市" prop="sbPersonCountQs">
        <el-input
          v-model="queryParams.sbPersonCountQs"
          placeholder="请输入社保人数_全市"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="社保金额_全市" prop="sbPayAmontSumQs">
        <el-input
          v-model="queryParams.sbPayAmontSumQs"
          placeholder="请输入社保金额_全市"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公积金人数" prop="gjjPersonCount">
        <el-input
          v-model="queryParams.gjjPersonCount"
          placeholder="请输入公积金人数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公积金金额" prop="gjjPayAmontSum">
        <el-input
          v-model="queryParams.gjjPayAmontSum"
          placeholder="请输入公积金金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公积金人数_全市" prop="gjjPersonCountQs">
        <el-input
          v-model="queryParams.gjjPersonCountQs"
          placeholder="请输入公积金人数_全市"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公积金金额_全市" prop="gjjPayAmontSumQs">
        <el-input
          v-model="queryParams.gjjPayAmontSumQs"
          placeholder="请输入公积金金额_全市"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="融资金额" prop="loanNumBalance">
        <el-input
          v-model="queryParams.loanNumBalance"
          placeholder="请输入融资金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="融资金额_全市" prop="loanNumBalanceQs">
        <el-input
          v-model="queryParams.loanNumBalanceQs"
          placeholder="请输入融资金额_全市"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['bigscreen:dnIndexq:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['bigscreen:dnIndexq:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['bigscreen:dnIndexq:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['bigscreen:dnIndexq:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="dnIndexqList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="等级" align="center" prop="lvl" />
      <el-table-column label="产业类型" align="center" prop="lx" />
      <el-table-column label="一级分类" align="center" prop="cpcc" />
      <el-table-column label="二级分类" align="center" prop="cpmc" />
      <el-table-column label="三级分类" align="center" prop="cpxf" />
      <el-table-column label="观察日期" align="center" prop="mon" />
      <el-table-column label="企业总数" align="center" prop="qys" />
      <el-table-column label="全市企业总数" align="center" prop="ctQs" />
      <el-table-column label="纳税金额" align="center" prop="taxAmount" />
      <el-table-column label="纳税金额_全市" align="center" prop="taxAmountQs" />
      <el-table-column label="社保人数" align="center" prop="sbPersonCount" />
      <el-table-column label="社保金额" align="center" prop="sbPayAmontSum" />
      <el-table-column label="社保人数_全市" align="center" prop="sbPersonCountQs" />
      <el-table-column label="社保金额_全市" align="center" prop="sbPayAmontSumQs" />
      <el-table-column label="公积金人数" align="center" prop="gjjPersonCount" />
      <el-table-column label="公积金金额" align="center" prop="gjjPayAmontSum" />
      <el-table-column label="公积金人数_全市" align="center" prop="gjjPersonCountQs" />
      <el-table-column label="公积金金额_全市" align="center" prop="gjjPayAmontSumQs" />
      <el-table-column label="融资金额" align="center" prop="loanNumBalance" />
      <el-table-column label="融资金额_全市" align="center" prop="loanNumBalanceQs" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['bigscreen:dnIndexq:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['bigscreen:dnIndexq:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改产业大脑_标签(季度)对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="等级" prop="lvl">
          <el-input v-model="form.lvl" placeholder="请输入等级" />
        </el-form-item>
        <el-form-item label="产业类型" prop="lx">
          <el-input v-model="form.lx" placeholder="请输入产业类型" />
        </el-form-item>
        <el-form-item label="一级分类" prop="cpcc">
          <el-input v-model="form.cpcc" placeholder="请输入一级分类" />
        </el-form-item>
        <el-form-item label="二级分类" prop="cpmc">
          <el-input v-model="form.cpmc" placeholder="请输入二级分类" />
        </el-form-item>
        <el-form-item label="三级分类" prop="cpxf">
          <el-input v-model="form.cpxf" placeholder="请输入三级分类" />
        </el-form-item>
        <el-form-item label="观察日期" prop="mon">
          <el-input v-model="form.mon" placeholder="请输入观察日期" />
        </el-form-item>
        <el-form-item label="企业总数" prop="qys">
          <el-input v-model="form.qys" placeholder="请输入企业总数" />
        </el-form-item>
        <el-form-item label="全市企业总数" prop="ctQs">
          <el-input v-model="form.ctQs" placeholder="请输入全市企业总数" />
        </el-form-item>
        <el-form-item label="纳税金额" prop="taxAmount">
          <el-input v-model="form.taxAmount" placeholder="请输入纳税金额" />
        </el-form-item>
        <el-form-item label="纳税金额_全市" prop="taxAmountQs">
          <el-input v-model="form.taxAmountQs" placeholder="请输入纳税金额_全市" />
        </el-form-item>
        <el-form-item label="社保人数" prop="sbPersonCount">
          <el-input v-model="form.sbPersonCount" placeholder="请输入社保人数" />
        </el-form-item>
        <el-form-item label="社保金额" prop="sbPayAmontSum">
          <el-input v-model="form.sbPayAmontSum" placeholder="请输入社保金额" />
        </el-form-item>
        <el-form-item label="社保人数_全市" prop="sbPersonCountQs">
          <el-input v-model="form.sbPersonCountQs" placeholder="请输入社保人数_全市" />
        </el-form-item>
        <el-form-item label="社保金额_全市" prop="sbPayAmontSumQs">
          <el-input v-model="form.sbPayAmontSumQs" placeholder="请输入社保金额_全市" />
        </el-form-item>
        <el-form-item label="公积金人数" prop="gjjPersonCount">
          <el-input v-model="form.gjjPersonCount" placeholder="请输入公积金人数" />
        </el-form-item>
        <el-form-item label="公积金金额" prop="gjjPayAmontSum">
          <el-input v-model="form.gjjPayAmontSum" placeholder="请输入公积金金额" />
        </el-form-item>
        <el-form-item label="公积金人数_全市" prop="gjjPersonCountQs">
          <el-input v-model="form.gjjPersonCountQs" placeholder="请输入公积金人数_全市" />
        </el-form-item>
        <el-form-item label="公积金金额_全市" prop="gjjPayAmontSumQs">
          <el-input v-model="form.gjjPayAmontSumQs" placeholder="请输入公积金金额_全市" />
        </el-form-item>
        <el-form-item label="融资金额" prop="loanNumBalance">
          <el-input v-model="form.loanNumBalance" placeholder="请输入融资金额" />
        </el-form-item>
        <el-form-item label="融资金额_全市" prop="loanNumBalanceQs">
          <el-input v-model="form.loanNumBalanceQs" placeholder="请输入融资金额_全市" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listDnIndexq, getDnIndexq, delDnIndexq, addDnIndexq, updateDnIndexq } from "@/api/industry/dnIndexq";

export default {
  name: "DnIndexq",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 产业大脑_标签(季度)表格数据
      dnIndexqList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        lvl: null,
        lx: null,
        cpcc: null,
        cpmc: null,
        cpxf: null,
        mon: null,
        qys: null,
        ctQs: null,
        taxAmount: null,
        taxAmountQs: null,
        sbPersonCount: null,
        sbPayAmontSum: null,
        sbPersonCountQs: null,
        sbPayAmontSumQs: null,
        gjjPersonCount: null,
        gjjPayAmontSum: null,
        gjjPersonCountQs: null,
        gjjPayAmontSumQs: null,
        loanNumBalance: null,
        loanNumBalanceQs: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询产业大脑_标签(季度)列表 */
    getList() {
      this.loading = true;
      listDnIndexq(this.queryParams).then(response => {
        this.dnIndexqList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        lvl: null,
        lx: null,
        cpcc: null,
        cpmc: null,
        cpxf: null,
        mon: null,
        qys: null,
        ctQs: null,
        taxAmount: null,
        taxAmountQs: null,
        sbPersonCount: null,
        sbPayAmontSum: null,
        sbPersonCountQs: null,
        sbPayAmontSumQs: null,
        gjjPersonCount: null,
        gjjPayAmontSum: null,
        gjjPersonCountQs: null,
        gjjPayAmontSumQs: null,
        loanNumBalance: null,
        loanNumBalanceQs: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.lvl)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加产业大脑_标签(季度)";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const lvl = row.lvl || this.ids
      getDnIndexq(lvl).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改产业大脑_标签(季度)";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.lvl != null) {
            updateDnIndexq(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addDnIndexq(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const lvls = row.lvl || this.ids;
      this.$modal.confirm('是否确认删除产业大脑_标签(季度)编号为"' + lvls + '"的数据项？').then(function() {
        return delDnIndexq(lvls);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('bigscreen/dnIndexq/export', {
        ...this.queryParams
      }, `dnIndexq_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
